<template>
	<!-- MES系统配置 -->
	<div>
		<v-card style="float: left;">
			<v-tabs vertical>
				<v-tab>
					系统邮件配置
				</v-tab>
				<v-tab>
					上传前端所有菜单
				</v-tab>
				<v-tab-item>
					<v-alert>发送系统邮件时使用此邮箱！</v-alert>
					<v-card flat>
						<v-card-text>
							<v-row>
								<v-col cols="12">
									<v-text-field v-model="systemEmailModel.userName" label="发送者名称" dense outlined>
									</v-text-field>
								</v-col>
								<v-col cols="12">
									<v-text-field v-model="systemEmailModel.userAddress" label="邮箱账号" dense outlined>
									</v-text-field>
								</v-col>
								<v-col cols="12">
									<v-text-field v-model="systemEmailModel.password" label="邮箱密码" dense outlined>
									</v-text-field>
								</v-col>
								<v-col cols="12">
									<v-text-field v-model="systemEmailModel.host" label="Host" dense outlined>
									</v-text-field>
								</v-col>
								<v-col cols="12">
									<v-text-field v-model="systemEmailModel.port" label="Port" dense outlined>
									</v-text-field>
								</v-col>
								<v-col cols="12">
									<v-checkbox v-model="systemEmailModel.useSsl" label="使用Ssl" dense outlined>
									</v-checkbox>
								</v-col>
							</v-row>
						</v-card-text>
						<v-card-actions>
							<v-spacer></v-spacer>
							<div>
								<v-btn class="ml-3" color="success" text @click="systemEmailSubmit">
									确定
								</v-btn>
							</div>
						</v-card-actions>
					</v-card>
				</v-tab-item>
				<v-tab-item>
					<v-alert>上传前端的菜单及前端的菜单路径与数据表匹配</v-alert>
					<v-card width="100%">
						<v-card-text>
							<v-btn @click="UpLoadMenus">上传前端所有菜单</v-btn>
						</v-card-text>
					</v-card>
				</v-tab-item>
			</v-tabs>
		</v-card>
	</div>
</template>

<script>
	import setting from "@/setting.js";
	import {
		menuAside
	} from "@/menu/index.js";
	export default {
		name: 'mes_mes_config',
		data: () => ({
			systemEmailModel: {
				'UseSsl': false
			},
			menus: menuAside
		}),
		created() {
			this.loadSystemEmail()
		},
		methods: {
			async UpLoadMenus() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/UpLoadMenus`,
					method: 'post',
					data: this.menus
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			async loadSystemEmail() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/GetSystemEmail`,
					method: 'post'
				}) 

				if (response.status == 1) {
					this.systemEmailModel = response.data
				}
			},
			async systemEmailSubmit() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/EditEmail`,
					method: 'post',
					data: this.systemEmailModel
				})

				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
		}
	}
</script>

<style>
</style>
